home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / archiver / ldiff12s.zip / LDD.ASM < prev    next >
Assembly Source File  |  1989-07-15  |  6KB  |  245 lines

  1. ;-----------------------------------------------------------------------------;
  2. ; LDD.asm Ä½Åæî┼ÆΦÄ«üië≡ôÇüj       (C) ÄOû╪ÿaòF NIFTY SDR SDI00147   1989/7/15;
  3. ;-----------------------------------------------------------------------------;
  4. ; ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@    èεû{ôIé╚âAâïâSâèâYâÇé═ë£æ║Äüé╠ébé≡ÄQÅ╞;
  5. ; ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ ü@ü@ü@ü@ ì\æóë╗â}âNâìé═î├É∞Äüé╠éαé╠é≡Ägùp;
  6. ;                                          ;
  7. ;   ì∞ɼû@:                                      ;
  8. ;       optasm é≡ Use THREADs for Smaller OBJ(N) é╔é╡é─âAâZâôâuâïé╖éΘ         ;
  9. ;                                          ;
  10. ;-----------------------------------------------------------------------------;
  11. include lms3.inc                    ; ìéæ¼ì\æóë╗â}âNâì
  12.                             ; (c)S.Furukawa
  13. include minimac.inc                    ; movseg movdat movdatb
  14. ;-----------------------------------------------------------------------------;
  15. data    segment    word public                ;
  16.     extrn    RBuff        : byte            ; Åæì₧é▌âoâbâtâ@
  17.     extrn    WBuff        : byte            ; ô╟ì₧é▌âoâbâtâ@
  18.     extrn    CrcTable    : word            ; éâéÆéâùpâeü[âuâï
  19.     extrn    CRC        : word            ; éâéÆéâ
  20.     extrn    DicSeg        : word            ; Ä½Åæâoâbâtâ@
  21.                             ;
  22.         WPoint        dw    ?        ; Åæì₧é▌â|âCâôâ^
  23.         RPoint        dw    ?        ; ô╟ì₧é▌â|âCâôâ^
  24.         InHandle    dw    ?        ; ôⁿù═ânâôâhâï
  25.         OutHandle    dw    ?        ; Åoù═ânâôâhâï
  26.         PushSp        dw    ?        ; éôéÉæ▐ö≡ùpâÅü[âN
  27.         LzdSize        dw    ?,?        ; âtâ@âCâïâTâCâY
  28.         ReadEndPnt    dw    ?        ; âèü[âhùpâÅü[âN
  29.         DecodeFlg    dw    ?        ;
  30. data    ends                        ;
  31.                             ;
  32. code    segment    byte public                ;
  33.     assume    cs:code,ds:data,es:data            ;
  34.                             ;
  35.     public    DeCode                    ;
  36.                             ;
  37.     WBUFFEND    equ    0fffh            ;
  38.     RBUFFEND    equ    7fffh            ;
  39.                             ;
  40. ;-------------------------------------------------------;
  41. ; ébéqébîvÄZ                        ;
  42. ; ----------                        ;
  43. ;    in    cx,dx                    ;
  44. ;    out    --                    ;
  45. ;    des    --                    ;
  46. ;-------------------------------------------------------;
  47. BEGIN    CrcCalc                        ;
  48.     .if    <cxnz>                    ;
  49.         pushm    si,dx,cx,bx,ax            ;
  50.         mov    si,dx                ;
  51.         mov    dx,CRC                ;
  52.         .do                    ;
  53.             lodsb                ;
  54.             mov    bl,dl            ;
  55.             xor    bh,bh            ;
  56.             xor    bl,al            ;
  57.             shl    bx,1            ;
  58.             mov    ax,CrcTable[bx]        ;
  59.             mov    bl,dh            ;
  60.             xor    bh,bh            ;
  61.             xor    bx,ax            ;
  62.             mov    dx,bx            ;
  63.         .loop                    ;
  64.         mov    CRC,dx                ;
  65.         popm    ax,bx,cx,dx,si            ;
  66.     .endif                        ;
  67.     ret                        ;
  68. ENDN    CrcCalc                        ;
  69. ;-------------------------------------------------------;
  70. ; éüéîé≡Åoù═                        ;
  71. ; ----------                        ;
  72. ;    in    al                    ;
  73. ;    out    --                    ;
  74. ;    des    --                    ;
  75. ;-------------------------------------------------------;
  76. BEGIN    PutC                        ;
  77.     push    di                    ;
  78.     mov    di,WPoint                ;
  79.     .if    <di a WBUFFEND>                ;
  80.         pushm    ax,bx,cx,dx            ;
  81.         lea    dx,WBuff            ;
  82.         mov    cx,di                ;
  83.         mov    bx,OutHandle            ;
  84.         msdos    40h                ;
  85.         jc    ErrOut                ;
  86.         cmp    ax,cx                ;
  87.         jb    ErrOut                ;
  88.         call    CrcCalc                ;
  89.         popm    dx,cx,bx,ax            ;
  90.         xor    di,di                ;
  91.         mov    WPoint,di            ;
  92.     .endif                        ;
  93.     mov    WBuff[di],al                ;
  94.     inc    WPoint                    ;
  95.     pop    di                    ;
  96.     ret                        ;
  97. ENDN    PutC                        ;
  98. ;-------------------------------------------------------;
  99. ; âfü[â^ô╟é▌ì₧é▌                    ;
  100. ; --------------                    ;
  101. ;    in    --                    ;
  102. ;    out    al,cy                    ;
  103. ;    des    --                    ;
  104. ;-------------------------------------------------------;
  105. BEGIN    GetC                        ;
  106.     push    si                    ;
  107.     mov    si,RPoint                ;
  108.     .if    <si z 0>                ;
  109.         pushm    ax,bx,cx,dx            ;
  110.         mov    cx,RBUFFEND+1            ;
  111.         .if    <LzdSize[2] e 0 and <cx a LzdSize>>
  112.             mov    cx,LzdSize        ;
  113.         .endif                    ;
  114.         mov    bx,InHandle            ;
  115.         mov    dx,offset RBuff            ;
  116.         msdos    3fh                ;
  117.         jc    ErrOut                ;
  118.         cmp    ax,cx                ;
  119.         jc    ErrOut                ;
  120.         sub    LzdSize,ax            ;
  121.         sbb    LzdSize[2],0            ;
  122.         mov    ReadEndPnt,ax            ;
  123.         popm    dx,cx,bx,ax            ;
  124.     .endif                        ;
  125.     cmp    si,ReadEndPnt                ;
  126.     jae    EndPrg                    ;
  127.     mov    al,RBuff[si]                ;
  128.     inc    si                    ;
  129.     .if    <si a RBUFFEND>                ;
  130.         xor    si,si                ;
  131.     .endif                        ;
  132.     mov    RPoint,si                ;
  133.     pop    si                    ;
  134.            ret                        ;
  135. ENDN    GetC                        ;
  136. ;-----------------------------------------------------------------------------;
  137. ; DeCode(in:word,out:word;size:longint;flg:word):boolean              ;
  138. ;-----------------------------------------------------------------------------;
  139. BEGIN    OutCode16                    ;
  140.     call    GetC                    ;
  141.     mov    ah,al                    ;
  142.     call    GetC                    ;
  143.     xchg    ah,al                    ;
  144.     mov    si,ax                    ; Ä½Åæâ|âCâôâ^
  145.     call    GetC                    ;
  146.     mov    cl,al                    ;
  147.     call    GetC                    ;
  148.     mov    ch,al                    ;
  149.     add    cx,4                    ; ÆPîΩé╠æσé½é│
  150.     mov    ax,DicSeg                ;
  151.     mov    es,ax                    ; Ä½ÅæâZâOâüâôâg
  152.     .do                        ;
  153.         mov    al,es:[si]            ;
  154.         inc    si                ;
  155.         call    PutC                ;
  156.     .loop                        ;
  157.     ret                        ;
  158. ENDN    OutCode16                    ;
  159. ;-------------------------------------------------------;
  160. BEGIN    OutCode18                    ;
  161.     call    GetC                    ;
  162.     mov    ah,al                    ;
  163.     call    GetC                    ;
  164.     xchg    ah,al                    ;
  165.     mov    si,ax                    ; Ä½Åæâ|âCâôâ^
  166.     call    GetC                    ;
  167.     mov    ch,al                    ;
  168.     and    al,11000000b                ;
  169.     xor    ah,ah                    ;
  170.     xchg    ah,al                    ;
  171.     shr    ax,1                    ;
  172.     shr    ax,1                    ;
  173.     add    ax,DicSeg                ;
  174.     mov    es,ax                    ; Ä½ÅæâZâOâüâôâg
  175.     and    ch,00111111b                ;
  176.     call    GetC                    ;
  177.     mov    cl,al                    ;
  178.     add    cx,4                    ; ÆPîΩé╠æσé½é│
  179.     .do                        ;
  180.         mov    al,es:[si]            ;
  181.         inc    si                ;
  182.         .if    <z>                ;
  183.             push    ax            ;
  184.             mov    ax,es            ;
  185.             add    ax,1000h        ;
  186.             mov    es,ax            ;
  187.             pop    ax            ;
  188.         .endif                    ;
  189.         call    PutC                ;
  190.     .loop                        ;
  191.     ret                        ;
  192. ENDN    OutCode18                    ;
  193. ;-------------------------------------------------------;
  194. BEGIN    DeCode                        ;
  195.     cld                        ;
  196.     mov    bx,sp                    ;
  197.     mov    PushSp,sp                ;
  198.     movdat    InHandle  ,ss:[bx+10]            ;
  199.     movdat    OutHandle ,ss:[bx+8]            ;
  200.     movdat    LzdSize[2],ss:[bx+6]            ;
  201.     movdat    LzdSize   ,ss:[bx+4]            ;
  202.     movdat    DecodeFlg ,ss:[bx+2]            ;
  203.     mov    RPoint,0                ;
  204.     mov    WPoint,0                ;
  205.     mov    dl,10000000b                ; dl âVâtâgâJâEâôâg
  206.     .do                        ; dh âVâtâgâtâëâO
  207.         rol    dl,1                ;
  208.         .if    <c>                ;
  209.             call    GetC            ;
  210.             mov    dh,al            ;
  211.             mov    dl,1            ;
  212.         .endif                    ;
  213.         test    dh,dl                ;
  214.         .if    <nz>                ;
  215.             call    GetC            ;
  216.             call    PutC            ;
  217.         .else                    ;
  218.             .if    <DecodeFlg e 16>    ;
  219.                 call    OutCode16    ;
  220.             .else                ;
  221.                 call    OutCode18    ;
  222.             .endif                ;
  223.         .endif                    ;
  224.     .enddo    <>                    ;
  225. EndPrg:    lea    dx,WBuff                ;
  226.     mov    bx,OutHandle                ;
  227.     mov    cx,WPoint                ;
  228.     jcxz    NrmOut                    ;
  229.     msdos    40h                    ;
  230.     .if    <nc and <ax e cx>>            ;
  231.         call    CrcCalc                ;
  232.         jmp    NrmOut                ;
  233.     .endif                        ;
  234. ErrOut:    xor    ax,ax                    ;
  235.     jmp    OutPro                    ;
  236. NrmOut:    mov    ax,1                    ;
  237. OutPro:    mov    sp,PushSp                ;
  238.     ret    10                    ;
  239. ENDN    DeCode                        ;
  240.                             ;
  241.                             ;
  242. code    ends                        ;
  243.     end                        ;
  244. ;------------------------------------------------------------------------------
  245.